package org.smile.db.criteria;

import java.util.Map;

public abstract  class WhereCriterionVisitor extends BaseCriterionVisitor{

    @Override
    public void visit(OtherFieldCriterion criterion) {
        whereSql.append(toColumnName(criterion.getFieldName())).append(" ").append(criterion.getOp()).append(" ");
        whereSql.append(toColumnName(criterion.getOtherField())).append(" ");
    }

    protected abstract String toColumnName(String fieldName);

    @Override
    public void visit(IsNullCriterion criterion) {
        whereSql.append(" ").append(toColumnName(criterion.getFieldName())).append(criterion.isIsnull()?" is null ":" is not null ");
    }

    @Override
    public void visit(OrderbyCriterion criterion) {
        whereSql.append(" ").append(toColumnName(criterion.getFieldName())).append(" ").append(criterion.getDesc());
    }

}
